#include<stdio.h>
#include<string.h>

int main(){
    char str_a[106];
    char str_b[106];
    int alpha_a[26] = {0};
    int alpha_b[26] = {0};
    int table_a[106] = {0};
    int table_b[106] = {0};
    gets(str_a);
    gets(str_b);
    int len_a = strlen(str_a);
    int len_b = strlen(str_b);
    if(len_a != len_b){
        printf("false\n");
        return 0;
    }

    int i;
    for(i = 0; i < len_a; i++){
        alpha_a[str_a[i] - 'a']++;
        alpha_b[str_b[i] - 'a']++;
    }
    for(i = 0; i < 26; i++){
        if((alpha_a[i] == 0 && alpha_b[i] != 0) || (alpha_b[i] == 0 && alpha_a[i] != 0)){
            printf("false\n");
            return 0;
        }
    }

    for(i = 0; i < 26; i++){
        table_a[alpha_a[i]]++;
        table_b[alpha_a[i]]++;
    }
    for(i = 0; i < 106; i++){
        if(table_a[i] != table_b[i]){
            printf("false\n");
            return 0;
        }
    }
    printf("true\n");
    return 0;
}